<template>
	<view class="container">
		<!-- 添加渐变背景 -->
		<view class="gradient-background"></view>
		
		<!-- 顶部安全区域 - 专为微信小程序设计 -->
		<view class="safe-area-top" :style="{ height: statusBarHeight + 'px' }"></view>
		
		<!-- 标题栏 -->
		<view class="title-bar">
			<text class="title-text">AI翻译</text>
			<view class="search-icon">
				<image src="/static/icon/shousuo.png" mode="aspectFit"></image>
			</view>
		</view>
		
		<!-- 单词卡片 - 使用固定距离 -->
		<view class="word-card">
			<view class="word-wrapper">
				<text class="word">Conception</text>
				<view class="audio-btn">
					<image src="/static/icon/audio.png" mode="aspectFit"></image>
					<text class="phonetic">[kən'sepʃn]</text>
				</view>
			</view>
			<view class="card-bottom">
				<view class="spacer"></view>
				<view class="add-vocab-btn">
					<text>添加生词本</text>
				</view>
			</view>
		</view>
		
		<!-- 内容区域 -->
		<scroll-view 
			class="content-area" 
			scroll-y 
			:scroll-with-animation="true"
			:enhanced="true"
			:show-scrollbar="false"
			:bounces="true"
		>
			<!-- AI翻译 -->
			<view class="section">
				<view class="section-header ai-translate">
					<text class="section-title">AI翻译</text>
				</view>
				<view class="section-content">
					<text class="translation-text gradient-text">这个词涵盖了思维认知的过程。在艺术领域中，它不仅表达了思维的起点，也展示了思维的过程。在艺术创作中，它代表了最初的灵感火花。在艺术生命中，它标志着新生命的开始。</text>
				</view>
			</view>
			
			<!-- 趣味记忆 -->
			<view class="section">
				<view class="section-header">
					<text class="section-title">趣味记忆</text>
				</view>
				<view class="section-content">
					<text class="memory-text">"构思灵感"，可以想象成脑海中灵感火花迸发的那一刻。这个词可以拆解为: con (共同) + cept (抓住) → 把多个想法抓在一起形成概念。</text>
				</view>
			</view>
			
			<!-- 释义与例句 -->
			<view class="section">
				<view class="section-header">
					<text class="section-title">释义与例句</text>
				</view>
				<view class="section-content">
					<text class="example-text">This conception of this plan is very creative.</text>
					<text class="example-translation">这个计划概念非常有创意</text>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
			statusBarHeight: 0
		}
	},
	onLoad() {
		// #ifdef MP-WEIXIN
		// 获取状态栏高度
		const sysInfo = wx.getSystemInfoSync();
		this.statusBarHeight = sysInfo.statusBarHeight;
		// #endif
		
		// #ifndef MP-WEIXIN
		// 其他平台
		uni.getSystemInfo({
			success: (res) => {
				this.statusBarHeight = res.statusBarHeight;
			}
		});
		// #endif
		}
	}
</script>

<style lang="scss">
page {
	height: 100%;
	overflow: hidden;
}

	.container {
	display: flex;
	flex-direction: column;
	align-items: center;
	width: 100%;
	height: 100vh;
	background-color: #FFFFFF;
	position: relative;

	.gradient-background {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 40vh;
		background: linear-gradient(to bottom, #E4F2FF, #FFFFFF);
		z-index: 0;
	}
	
	/* 顶部安全区域 - 为状态栏预留空间 */
	.safe-area-top {
		width: 100%;
		background: transparent;
		position: relative;
		z-index: 99;
	}

	/* 标题栏 */
	.title-bar {
		width: 90%;
		height: 88rpx;
		margin: 80rpx 0rpx 0rpx 0rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		position: relative;
		z-index: 99;
		
		.title-text {
			font-size: 36rpx;
			font-weight: bold;
			color: #333;
		}
		
		.search-icon {
			width: 64rpx;
			height: 64rpx;
			
			image {
				width: 100%;
				height: 100%;
			}
		}
	}

	/* 单词卡片 */
	.word-card {
		width: 90%;
		background: linear-gradient(to right, #3D9BEF, #00D0FF);
		border-radius: 24rpx;
		padding: 30rpx;
		display: flex;
		justify-content: space-between;
		margin-top:10rpx;
		margin-bottom: 30rpx;
		position: relative;
		z-index: 99;
		box-sizing: border-box;

		.word-wrapper {
			display: flex;
			flex-direction: column;
			width: 100%;

			.word {
				color: #FFFFFF;
				font-size: 48rpx;
				font-weight: 600;
			}

			.audio-btn {
				margin-top: 20rpx;
				display: flex;
				align-items: center;
				gap: 20rpx;

				.phonetic {
					color: white;
					font-size: 32rpx;
				}

				image {
					width: 40rpx;
					height: 40rpx;
				}
			}
		}
		
		.card-bottom {
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-top: 20rpx;
			width: 100%;
			
			.spacer {
				flex: 1;
			}

			.add-vocab-btn {
				background-color: white;
				padding: 12rpx 24rpx;
				border-radius: 30rpx;
				text-align: center;
				width: 180rpx;
				box-sizing: border-box;
				
				text {
					font-size: 24rpx;
					color: #3D9BEF;
				}
			}
		}
	}

	/* 内容区域 */
	.content-area {
		width: 90%;
		max-height: 60vh;
		padding-bottom: 40rpx;
		-webkit-overflow-scrolling: touch;
		position: relative;
		z-index: 98;

		.section {
			margin-bottom: 40rpx;
			width: 100%;

			.section-header {
				margin-bottom: 20rpx;
				display: inline-block;
				background-color: #EEF7FF;
				padding: 16rpx 30rpx;
				border-radius: 100rpx;

				&.ai-translate {
					.section-title {
						/* 微信小程序渐变文本处理 */
						/* #ifdef MP-WEIXIN */
						background-image: linear-gradient(to right, #9F00A2, #FFA100);
						-webkit-background-clip: text;
						-webkit-text-fill-color: transparent;
						/* #endif */
						
						/* 其他平台处理 */
						/* #ifndef MP-WEIXIN */
						background: linear-gradient(to right, #9F00A2, #FFA100);
						-webkit-background-clip: text;
						background-clip: text;
						color: transparent;
						/* #endif */
					}
				}

				.section-title {
					font-size: 28rpx;
					font-weight: bold;
					color: #1079DA;
				}
			}

			.section-content {
				background-color: white;
				border-radius: 16rpx;
				padding: 30rpx;
				font-size: 26rpx;
				line-height: 1.6;
				white-space: pre-wrap;
				box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);

				.translation-text, .memory-text, .example-text, .example-translation {
					font-size: 26rpx;
					color: #666666;
					line-height: 1.5;
				}
				
				.gradient-text {
					/* 微信小程序渐变文本处理 */
					/* #ifdef MP-WEIXIN */
					background-image: linear-gradient(to right, #9F00A2, #FFA100);
					-webkit-background-clip: text;
					-webkit-text-fill-color: transparent;
					/* #endif */
					
					/* 其他平台处理 */
					/* #ifndef MP-WEIXIN */
					background: linear-gradient(to right, #9F00A2, #FFA100);
					-webkit-background-clip: text;
					background-clip: text;
					color: transparent;
					/* #endif */
				}

				.example-text {
					color: #3A94E7;
					display: block;
					margin-bottom: 16rpx;
				}

				.example-translation {
					color: #898989;
					display: block;
				}
			}
		}
	}
	}
</style>
